package com.wy.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wy.dao.User;
import com.wy.dao.UserParam;
import com.wy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author 33117
 * @version 1.0
 * @data 2025/3/1 16:12
 */
@RestController
@RequestMapping("user")
public class UserController {
    public static String Name;
    @Autowired
    UserService userService;

    @PostMapping("/list")
    public List<User> list(@RequestBody UserParam userParam) {
        List<User> list = userService.list(userParam);
        return list;
    }

    @GetMapping("listt")
    public List<User> listpage(@RequestParam(value = "name",required = false) String name) {
        Name =name;
        List<User> listpage = userService.listpage(name);
        return listpage;
    }

    @GetMapping("getCreateTime")
    public List<User> getCreateTime(@RequestParam(value = "createTime",required =false)
                                    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime time) {
        List<User> createList = userService.findGetName(time);
        System.out.println(createList + "-------------------------");
        return createList;
    }
}
